from abc import ABC, abstractmethod
import pandas as pd
from typing import Dict, List


class IBaseSubjects(ABC):
    @abstractmethod
    def get_qualified_subjects(self) -> pd.DataFrame:
        pass


class IJoiner(ABC):
    @abstractmethod
    def join_tables_by_subject(self, base_df: pd.DataFrame, input_excel_path: str, join_key: str, skip_missing_key: bool) -> Dict[str, pd.DataFrame]:
        pass


class IPivotMetrics(ABC):
    @abstractmethod
    def verify_key_metrics(self, config: Dict) -> pd.DataFrame:
        pass


class IFailureList(ABC):
    @abstractmethod
    def get_failure_list(self) -> pd.DataFrame:
        pass


class ICycleProcessor(ABC):
    @abstractmethod
    def process_cycles(self, all_results: Dict[str, pd.DataFrame], cycle: List[str], sources: List[str]) -> None:
        pass


class IBloodDraw(ABC):
    @abstractmethod
    def process_blood_draw(self, all_results: Dict[str, pd.DataFrame]) -> None:
        """读取 BloodDraw 模块数据并按 数据节+行号 透视，输出到 all_results 中。"""
        pass


class ILbup(ABC):
    @abstractmethod
    def process_lbup(self, all_results: Dict[str, pd.DataFrame]) -> None:
        """读取 IsLbup 模块数据，按 LBREAS 定义筛选期/出组，透视 [LBSCAT, LBREAS]，并合并输出到 all_results['IsLbup']。"""
        pass


class IDataPivot(ABC):
    @abstractmethod
    def perform_pivot(self, config: Dict) -> pd.DataFrame:
        """通用多维数据透视接口，入参包含 sheet_name/base_cols/merge_keys/group_dims/value_cols。"""
        pass
